package treeview.container.wrapped;

import document.Context;
import treemodel.Unit;
import treeview.container.HorizontalContainer;
import treeview.container.WrappedHorizontalContainer;
import treeview.unit.IndentView;

import java.awt.*;
import java.util.ArrayList;

/**
 * Created by Pavel Nikolaev
 */
public class IndentedLineView extends WrappedHorizontalContainer {
    protected Context myContext;

    public IndentedLineView(ArrayList<Unit> units, Context context) {
        super(units, context);
        this.myContext = context;
    }

    @Override
    protected HorizontalContainer createFirstSubLine() {
        HorizontalContainer line = new HorizontalContainer();
        line.add(new IndentView(myContext));
        return line;
    }

    @Override
    protected HorizontalContainer createSubLine() {
        return createFirstSubLine();
    }

    @Override
    public void fitIntoWidth(Graphics g, int widthToFitInto) {
        widthToFitInto -= myContext.getListIndentWidth();
        super.fitIntoWidth(g, widthToFitInto);
    }
}
